﻿package{
	//import flash.display.Scene;
	import flash.display.Sprite;
	import flash.events.Event;
	
	import org.papervision3d.view.Viewport3D;
	import org.papervision3d.scenes.Scene3D;
	import org.papervision3d.cameras.Camera3D;
	import org.papervision3d.render.BasicRenderEngine;
	import org.papervision3d.objects.DisplayObject3D;
	//import org.papervision3d.materials.MovieAssetMaterial;
	import org.papervision3d.materials.WireframeMaterial;
	import org.papervision3d.objects.primitives.Plane;
	
	public class Start_ver2 extends Sprite
	{
		private var viewPort:Viewport3D;
		private var scene:Scene3D;
		private var camera:Camera3D;
		private var renderer:BasicRenderEngine;
		private var dispObj3D:DisplayObject3D;
		
		public function Start_ver2():void
		{
			init3D();
			createObj();
		}
		private function init3D():void
		{
			viewPort = new Viewport3D(550,400);	
			addChild(viewPort);
			
			scene = new Scene3D();
			camera = new Camera3D();
			renderer = new BasicRenderEngine();
			
			dispObj3D = new DisplayObject3D('Start');
			scene.addChild(dispObj3D);
			
			addEventListener(Event.ENTER_FRAME,enterFrame);
		}
		
		private function createObj():void
		{
			//var material:MovieAssetMaterial = new MovieAssetMaterial('Obj');
			var material:WireframeMaterial = new WireframeMaterial(0xFFFFFF);
			material.doubleSided=true;
			var plane:Plane = new Plane(material, 200, 200, 8, 8 );
			dispObj3D.addChild(plane);			
		}
		
		private function enterFrame(_e:Event):void
		{
			dispObj3D.rotationY += 2;
			renderer.renderScene(scene,camera,viewPort);
		}
	}
}